package com.annotation.service;

import com.annotation.dao.BookDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.annotation.Resource;
import javax.inject.Inject;

@Service
public class BookService {

    @Inject
//    @Resource
//    @Qualifier("bookDao2")
    @Autowired(required = false)
    private BookDao bookDao;

    public BookDao getBookDao() {
        return bookDao;
    }

    public void setBookDao(BookDao bookDao) {
        this.bookDao = bookDao;
    }

    @PostConstruct
    public void init(){
        System.out.println(bookDao);
    }

    @PreDestroy
    public void destroy(){
        System.out.println("BookService destroy");
    }
}
